Skip to content

fix glob-to-regexp d.ts - #49

Merged
AlexTugarev merged 1 commit into
masterfrom
at/fix-typedefinition
Feb 3, 2018
Merged

fix glob-to-regexp d.ts#49
AlexTugarev merged 1 commit into
masterfrom
at/fix-typedefinition

Conversation

@AlexTugarev

Copy link
Copy Markdown
Contributor

Signed-off-by: Alex Tugarev alex.tugarev@typefox.io

@AlexTugarev
AlexTugarev requested a review from akosyakov February 1, 2018 13:14
@AlexTugarev

Copy link
Copy Markdown
Contributor Author

The issue is, that DocumentFilters like { pattern: ".*"} cannot be used, as the type definition refers to an ES6 module, but glob-to-regexp is not a such. Also, the function is only called if only pattern is provided.

@@ -1,7 +1,9 @@
declare module "glob-to-regexp" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to delcare module then at all? https://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-function-d-ts.html looks like we should be able to declare a function and export it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module declaration is needed if import ... from "module" syntax should stay, cf. microsoft/TypeScript#5073.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we use import x = require('module') then it should not be necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, it's still required.

[ts]
Could not find a declaration file for module 'glob-to-regexp'. '/Users/tugarev/Projects/monaco-languageclient/node_modules/glob-to-regexp/index.js' implicitly has an 'any' type.
Try npm install @types/glob-to-regexp if it exists or add a new declaration (.d.ts) file containing declare module 'glob-to-regexp';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double-checked that, it's required if types should be imported, right? module-function.d.ts seems to be misleading.

Comment thread src/languages.ts Outdated
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
import globToRegExp from "glob-to-regexp";
import * as globToRegExp from 'glob-to-regexp';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import globToRegExp = require('glob-to-regexp') should be used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I change it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please, I think it is bogus to use es6 syntax to import not es6 modules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Signed-off-by: Alex Tugarev <alex.tugarev@typefox.io>
@AlexTugarev
AlexTugarev force-pushed the at/fix-typedefinition branch from 18e6c3d to d6424cd Compare February 1, 2018 14:08
@akosyakov

Copy link
Copy Markdown
Contributor

@AlexTugarev I've sent you an invitation, please accept it and merge the PR

@AlexTugarev
AlexTugarev merged commit 1050734 into master Feb 3, 2018
@AlexTugarev
AlexTugarev deleted the at/fix-typedefinition branch February 3, 2018 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants